package nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * Created by Administrator on 2016/6/12 0012.
 */
public class HomeItemCart implements Parcelable {
    public String unitId="";
    public String title="";
    public float one_price;
    public int weight;
    public String image="";
    public int num;
    public float total_money;
    public boolean isSelect;
    public int hotType;
    public float getOnePiece(){
        return one_price/weight;
    }

    public int getTotalWeight(){
        return num*weight;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.unitId);
        dest.writeString(this.title);
        dest.writeFloat(this.one_price);
        dest.writeInt(this.weight);
        dest.writeString(this.image);
        dest.writeInt(this.num);
        dest.writeFloat(this.total_money);
        dest.writeByte(this.isSelect ? (byte) 1 : (byte) 0);
        dest.writeInt(this.hotType);
    }

    public HomeItemCart() {
    }

    protected HomeItemCart(Parcel in) {
        this.unitId = in.readString();
        this.title = in.readString();
        this.one_price = in.readFloat();
        this.weight = in.readInt();
        this.image = in.readString();
        this.num = in.readInt();
        this.total_money = in.readFloat();
        this.isSelect = in.readByte() != 0;
        this.hotType = in.readInt();
    }

    public static final Parcelable.Creator<HomeItemCart> CREATOR = new Parcelable.Creator<HomeItemCart>() {
        @Override
        public HomeItemCart createFromParcel(Parcel source) {
            return new HomeItemCart(source);
        }

        @Override
        public HomeItemCart[] newArray(int size) {
            return new HomeItemCart[size];
        }
    };
}
